<template>
  <div>
    <div style="background-color: #ffffff">
      <span> 商铺编号 </span>
      <el-select v-model="id" placeholder="商铺完整编号">
        <el-option v-for="(item, index) in listId" :key="index" :label="item" :value="item">
        </el-option>
      </el-select>
      <el-button type="primary" icon="el-icon-search" @click="showSelectMessage">搜索</el-button>
    </div>

    <div style="margin-top: 20px; background-color: #ffffff">
      <el-descriptions>
        <el-descriptions-item label="编号">{{ name }}</el-descriptions-item>
        <el-descriptions-item label="商铺状态">{{ state }}</el-descriptions-item>
        <el-descriptions-item label="到期日期">{{ state_end_time }}</el-descriptions-item>
        <el-descriptions-item label="占地面积"> {{ building_square }} </el-descriptions-item>
        <el-descriptions-item label="使用面积">{{ use_square }}</el-descriptions-item>
        <el-descriptions-item label="行业">{{ user_trade }}</el-descriptions-item>
        <el-descriptions-item label="客户姓名">{{ user_name }}</el-descriptions-item>
        <el-descriptions-item label="联系方式"> {{ user_phone }} </el-descriptions-item>
        <el-descriptions-item label="入住时间">{{ begin_date }}</el-descriptions-item>
      </el-descriptions>

    </div>
    <div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="常规收费" name="first">
          <el-button type="primary" icon="el-icon-search" @click="visible=true"> 收费</el-button>
          <el-button style="margin-left: 30px" type="primary" @click="visible11=true" icon="el-icon-search">历史信息</el-button>
          <div>
            <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
              <el-table-column type="selection" show-overflow-tooltip>
              </el-table-column>

              <el-table-column prop="feeItemName" label="收费项目名" show-overflow-tooltip>
              </el-table-column>
              <el-table-column prop="beginDate" label="起收日期" show-overflow-tooltip>
              </el-table-column>
              <el-table-column prop="endDate" label="到期日期" show-overflow-tooltip>
              </el-table-column>
              <el-table-column prop="deadline" label="缴费限制" show-overflow-tooltip>
              </el-table-column>
              <el-table-column prop="price" label="单价" show-overflow-tooltip>
              </el-table-column>
              <el-table-column prop="num" label="数量" show-overflow-tooltip>
              </el-table-column>
              <el-table-column prop="total" label="金额" show-overflow-tooltip>
              </el-table-column>
            </el-table>

          </div>
        </el-tab-pane>

        <el-tab-pane label="临时收费" name="second">
          <el-button type="primary" icon="el-icon-search" @click="visible1=true">收费</el-button>
          <el-dialog title="新建临时收费" :visible.sync="visible1">
            <el-form :model="Form" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
              <el-form-item label="商铺编号" prop="resourceName">
                <el-input v-model="Form.resourceName" :disabled="true"></el-input>
              </el-form-item>
              <el-form-item label="客户姓名" prop="feeUser" :disabled="true">
                <el-input v-model="Form.feeUser" :disabled="true"></el-input>
              </el-form-item>
              <el-form-item label="收费项目" prop="feeItemName">
                <el-select v-model="Form.feeItemName" placeholder="请选择">
                  <el-option v-for="(item, index) in configFeeItem" :key="index" :label="item" :value="item">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="付款方式" prop="paymethod">
                <el-select v-model="Form.paymethod" placeholder="请选择">
                  <el-option v-for="(item, index) in paymethods" :key="index" :label="item.name" :value="item.code">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="收费金额" prop="money">
                <el-input v-model="Form.money" placeholder="请输入"></el-input>
              </el-form-item>

              <el-form-item label="收费时间" required>
                <el-col :span="11">
                  <el-form-item prop="date1">
                    <el-date-picker value-format="yyyy-MM-dd" type="date" placeholder="选择日期" v-model="Form.date1" style="width: 100%"></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-form-item>
              <el-form-item style="margin-left: 300px">
                <el-button type="primary" @click="resetForms">取消</el-button>
                <el-button @click="addForm">确定</el-button>
              </el-form-item>
            </el-form>
          </el-dialog>

          <el-table :data="table" stripe style="width: 100%,margin-top:10px" :header-cell-style="{
          background: '#1890ff',
          color: '#ffffff',
          border: '1px #ffffff solid',
          'text-align': 'center',
        }" :cell-style="{ 'text-align': 'center' }">
            <el-table-column prop="id" label="序号"> </el-table-column>
            <el-table-column prop="feeUser" label="客户姓名"> </el-table-column>
            <el-table-column prop="feeItemName" label="收费项目"></el-table-column>
            <el-table-column prop="payType" label="付款方式"></el-table-column>
            <el-table-column prop="amt" label="收费金额"> </el-table-column>
            <el-table-column prop="operateUser " label="收款人"> </el-table-column>
            <el-table-column prop="operateTime" label="收款时间"> </el-table-column>
            <el-table-column prop="state" label="状态">
              <template slot-scope="scope">
                <el-tag type="success" v-if="scope.row.state === 'paied'">已付款</el-tag>
                <el-tag type="danger" v-else>未付款</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="remark" label="备注"> </el-table-column>
            <el-table-column prop="address" label="操作">
              <template slot-scope="scope">
                <el-button type="text" v-if="scope.row.state === 'paied'" @click="refund(scope.row)">退款</el-button>
                <el-button type="text" @click="shelf(scope.row)">打印</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="block">
            <el-pagination @size-change="handleSizeChange2" @current-change="handleCurrentChange2" :current-page="currentPage2" :page-sizes="[5, 10, 15, 20]" :page-size="1" layout="total, sizes, prev, pager, next, jumper" :total="total2">
            </el-pagination>
          </div>

        </el-tab-pane>

        <el-tab-pane label="收取押金" name="third">
          <el-button type="primary" @click="visible4=true" icon="el-icon-plus">新增</el-button>

          <el-dialog title="收取押金" :visible.sync="visible4">
            <el-form :model="ruleForm4" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
              <el-form-item label="客户类型">
                <!-- <el-radio-group > -->
                <el-radio v-model="radio" label="1">商铺客户</el-radio>
                <el-radio v-model="radio" label="2">非商铺客户</el-radio>
                <!-- </el-radio-group> -->
              </el-form-item>
              <el-form-item label="编号" prop="id" v-if="radio === '1'">
                <el-select v-model="ruleForm4.id" placeholder="商铺完整编号">
                  <el-option v-for="(item, index) in listId" :key="index" :label="item" :value="item">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="客户姓名" prop="name">
                <el-input v-model="ruleForm4.name"></el-input>
              </el-form-item>
              <el-form-item label="收费项目" prop="chargeitem">
                <el-select v-model="ruleForm4.chargeitem" placeholder="请选择">
                  <el-option v-for="(item, index) in configFeeItem" :key="index" :label="item" :value="item">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="付款方式" prop="paymethod">
                <el-select v-model="ruleForm4.paymethod" placeholder="请选择">
                  <el-option v-for="(item, index) in paymethods" :key="index" :label="item.name" :value="item.code">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="收费金额" prop="money">
                <el-input v-model="ruleForm4.money" placeholder="请输入"></el-input>
              </el-form-item>

              <el-form-item label="收费时间" required>
                <el-col :span="11">
                  <el-form-item prop="date1">
                    <el-date-picker value-format="yyyy-MM-dd" type="date" placeholder="选择日期" v-model="ruleForm4.date1" style="width: 100%"></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-form-item>

              <el-form-item style="margin-left: 300px">
                <el-button type="primary" @click="resetForms('ruleForm')">取消</el-button>
                <el-button @click="add">确定</el-button>
              </el-form-item>
            </el-form>
          </el-dialog>

          <el-table :data="tableData4" stripe style="width: 100%" :header-cell-style="{
                    background: '#1890ff',
                    color: '#ffffff',
                    border: '1px #ffffff solid',
                    'text-align': 'center',
                  }" :cell-style="{ 'text-align': 'center' }">
            <el-table-column prop="id" label="序号"> </el-table-column>
            <el-table-column prop="resourceName" label="编号"> </el-table-column>
            <el-table-column prop="feeUser" label="客户姓名"> </el-table-column>
            <el-table-column prop="feeItemName" label="收费项目"></el-table-column>
            <el-table-column prop="payType" label="付款方式"></el-table-column>
            <el-table-column prop="amt" label="收费金额"> </el-table-column>
            <el-table-column prop="operateUser " label="收款人"> </el-table-column>
            <el-table-column prop="operateTime" label="收款时间"> </el-table-column>
            <el-table-column prop="refundUser" label="退款人"> </el-table-column>
            <el-table-column prop="refundTime" label="退款时间"> </el-table-column>
            <el-table-column prop="state" label="状态">
              <template slot-scope="scope">
                <el-tag type="success" v-if="scope.row.state === 'refunded'">未退款</el-tag>
                <el-tag type="danger" v-else>已退款</el-tag>
              </template>
            </el-table-column>

            <el-table-column prop="remark" label="备注"> </el-table-column>
            <el-table-column prop="address" label="操作">
              <template slot-scope="scope">
                <el-button type="text" v-if="scope.row.state === 'refunded'" @click="refund(scope.row)">退款</el-button>
                <div style="text-align: left">
                  <el-dialog title="新建" :visible.sync="visible2">
                    <el-form :model="ruleForm1" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                      <el-form-item label="客户类型"> </el-form-item>
                      <el-form-item label="编号" prop="id" v-if="radio === '1'">
                        <el-select :disabled="true" v-model="ruleForm1.id" placeholder="商铺完整编号">
                          <el-option v-for="(item, index) in listId" :key="index" :label="item" :value="item" :disabled="true">
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="客户姓名" :disabled="true" prop="name">
                        <el-input v-model="ruleForm1.name" :disabled="true"></el-input>
                      </el-form-item>
                      <el-form-item label="收费项目" prop="chargeitem">
                        <el-select v-model="ruleForm1.chargeitem" :disabled="true" placeholder="请选择">
                          <el-option :disabled="true" v-for="chargeitem in chargeitems" :key="chargeitem.value" :label="chargeitem.label" :value="chargeitem.value">
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="付款方式" prop="paymethod">
                        <el-select v-model="ruleForm1.paymethod" :disabled="true" placeholder="请选择">
                          <el-option :disabled="true" v-for="(item, index) in paymethods" :key="index" :label="item.name" :value="item.code">
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item label="收费金额" prop="money" :disabled="true">
                        <el-input v-model="ruleForm1.money" :disabled="true" placeholder="请输入"></el-input>
                      </el-form-item>

                      <el-form-item label="收费时间" required :disabled="true">
                        <el-col :span="11">
                          <el-form-item prop="date1">
                            <el-date-picker :disabled="true" type="date" placeholder="选择日期" v-model="ruleForm1.date1" style="width: 100%"></el-date-picker>
                          </el-form-item>
                        </el-col>
                      </el-form-item>
                      <el-form-item label="退款时间" required>
                        <el-col :span="11">
                          <el-form-item prop="date2">
                            <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="ruleForm1.date2" style="width: 100%"></el-date-picker>
                          </el-form-item>
                        </el-col>
                      </el-form-item>

                      <el-form-item label="退款方式" prop="backmethod">
                        <el-select v-model="ruleForm1.backmethod" placeholder="请选择">
                          <el-option v-for="(item, index) in paymethods" :key="index" :label="item.name" :value="item.code">
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <div style="display: flex">
                        <span>备注 </span>
                        <el-input style="width: 200px" type="textarea" :rows="2" placeholder="请输入内容" v-model="ruleForm1.remark">
                        </el-input>
                      </div>

                      <el-form-item style="margin-left: 300px">
                        <el-button type="primary" @click="resetForm('ruleForm')">取消</el-button>
                        <el-button @click="updateForm,visible4=false">确定</el-button>
                      </el-form-item>
                    </el-form>
                  </el-dialog>
                </div>

                <el-button type="text" @click="shelf(scope.row)">打印</el-button>
              </template>
            </el-table-column>
          </el-table>

          <div>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage1" :page-sizes="[5, 10, 15, 20]" :page-size="5" layout="total, sizes, prev, pager, next, jumper" :total="total1">
            </el-pagination>
          </div>

        </el-tab-pane>
        <el-tab-pane label="预存款" name="fourth">
          <el-button type="primary" @click="visible3 = true" icon="el-icon-plus">预存</el-button>
          <el-button type="primary" @click="visible5 = true" icon="el-icon-plus">退还</el-button>

          <el-dialog title="预存" :visible.sync="visible3">
            <el-form :model="ruleForm2" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
              <el-form-item label="编号" prop="id" v-if="radio === '1'">
                <el-select v-model="ruleForm2.id" placeholder="商铺完整编号">
                  <el-option v-for="(item, index) in listId" :key="index" :label="item" :value="item">
                  </el-option>
                </el-select>

                <el-button type="primary" icon="el-icon-search" @click="selectPaymentTemp">搜索</el-button>
              </el-form-item>
              <el-form-item label="客户姓名" v-if="radio == '1'" prop="name">
                <el-input v-model="ruleForm2.name" :disabled="true"></el-input>
              </el-form-item>

              <el-form-item label="可用收费项">
                <!-- <el-radio-group > -->
                <el-radio v-model="paymoneyShow" label="1">指定收费项</el-radio>
                <el-radio v-model="paymoneyShow" label="2">所有收费项</el-radio>
                <!-- </el-radio-group> -->
              </el-form-item>

              <el-form-item label="收费项目" v-if="paymoneyShow == '1'" prop="chargeitem">
                <el-select v-model="ruleForm2.chargeitem" placeholder="请选择">
                  <el-option v-for="(item, index) in configFeeItem" :key="index" :label="item" :value="item">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="付款方式" prop="paymethod">
                <el-select v-model="ruleForm2.paymethod" placeholder="请选择">
                  <el-option v-for="(item, index) in paymethods" :key="index" :label="item.name" :value="item.code">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="收费金额" prop="money">
                <el-input v-model="ruleForm2.money" placeholder="请输入"></el-input>
              </el-form-item>

              <el-form-item label="收费时间" required>
                <el-col :span="11">
                  <el-form-item prop="date1">
                    <el-date-picker value-format="yyyy-MM-dd" type="date" placeholder="选择日期" v-model="ruleForm2.date1" style="width: 100%"></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-form-item>

              <el-form-item style="margin-left: 300px">
                <el-button type="primary" @click="resetForms1('ruleForm')">取消</el-button>
                <el-button @click="submitForm3">确定</el-button>
              </el-form-item>
            </el-form>
          </el-dialog>

          <el-dialog title="退还" :visible.sync="visible5">
            <el-form :model="ruleForm3" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
              <el-form-item label="编号" prop="id" v-if="radio === '1'">
                <el-select v-model="ruleForm1.id" placeholder="商铺完整编号">
                  <el-option v-for="(item, index) in listId" :key="index" :label="item" :value="item">
                  </el-option>
                </el-select>

                <el-button type="primary" icon="el-icon-search" @click="selectPaymentTemp">搜索</el-button>
              </el-form-item>
              <el-form-item label="客户姓名" v-if="radio == '1'" prop="name">
                <el-input v-model="ruleForm1.name" :disabled="true"></el-input>
              </el-form-item>

              <el-form-item label="退款方式" prop="paymethod">
                <el-select v-model="ruleForm1.paymethod" placeholder="请选择">
                  <el-option v-for="(item, index) in paymethods" :key="index" :label="item.name" :value="item.code">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="退款时间" required>
                <el-col :span="11">
                  <el-form-item prop="date1">
                    <el-date-picker value-format="yyyy-MM-dd" type="date" placeholder="选择日期" v-model="ruleForm1.date1" style="width: 100%"></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-form-item>
              <el-form-item style="text-align: left">
                <el-table :data="tableData2" border style="width: 100%">
                  <el-table-column type="index" label="序号" width="100"></el-table-column>
                  <el-table-column prop="feeItemId" label="收费项目" width="100%">
                  </el-table-column>
                  <el-table-column prop="amt" label="账号金额"> </el-table-column>
                  <el-table-column prop="backmoney" label="退还金额">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.backmoney" @input="handleInput(scope.$index,scope.row.backmoney)"></el-input>
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>

              <el-form-item style="margin-left: 300px">

                <el-button type="primary" @click="resetForm('ruleForm')">取消</el-button>

                <el-button @click="visible5=false">确定</el-button>
              </el-form-item>

            </el-form>
          </el-dialog>

          <el-table :data="tableData3" stripe style="width: 100%" :header-cell-style="{
          background: '#1890ff',
          color: '#ffffff',
          border: '1px #ffffff solid',
          'text-align': 'center',
        }" :cell-style="{ 'text-align': 'center' }">
            <el-table-column type="index" label="序号" width="100"></el-table-column>
            <el-table-column prop="resourceName" label="编号"> </el-table-column>
            <el-table-column prop="feeUser" label="客户姓名"> </el-table-column>
            <el-table-column prop="Type" label="状态">
              <template slot-scope="scope">
                <el-tag type="success" v-if="scope.row.type === 'pay'">支付</el-tag>
                <el-tag type="success" v-else-if="scope.row.type === 'add'">预存</el-tag>
                <el-tag type="success" v-else-if="scope.row.type === 'payAdd'">找零结账</el-tag>
                <el-tag type="success" v-else-if="scope.row.type === 'refuned'">退还</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="feeItemName" label="收费项目"></el-table-column>
            <el-table-column prop="payType" label="付款方式"> </el-table-column>
            <el-table-column prop="amt" label="金额"> </el-table-column>
            <el-table-column prop="operateUser" label="收款人"> </el-table-column>
            <el-table-column prop="operateTime" label="收款时间"> </el-table-column>
            <el-table-column prop="payNo" label="单号"> </el-table-column>
            <el-table-column prop="address" label="操作">
              <template slot-scope="scope">
                <el-button type="text" @click="refund(scope.row)">打印收款单</el-button>

                <el-button type="text" @click="shelf(scope.row)">打印退款单</el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="block">
            <el-pagination @size-change="handleSizeChange4" @current-change="handleCurrentChange4" :current-page="currentPage4" :page-sizes="[5, 10, 15, 20]" :page-size="1" layout="total, sizes, prev, pager, next, jumper" :total="total4">
            </el-pagination>
          </div>

        </el-tab-pane>
      </el-tabs>

      <el-dialog title="常规收费" :visible.sync="visible">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="150px" class="demo-ruleForm">
          <div>
            <el-table :data="tableData1" style="width: 100%">
              <el-table-column prop="feeItemName" label="收费项名" width="120">
              </el-table-column>
              <el-table-column prop="beginDate" label="费用开始时间" width="120">
              </el-table-column>
              <el-table-column prop="endDate" label="费用结束时间" width="110">
              </el-table-column>
              <el-table-column prop="discount" label="优惠金额" width="100%">
              </el-table-column>
              <el-table-column prop="lateFee" label="滞纳金" width="100%">
              </el-table-column>
              <el-table-column prop="total" label="应收金额" width="100%">
              </el-table-column>
            </el-table>
          </div>

          <div style="margin-top: 20px; background-color: #ffffff">
            <el-descriptions>
              <el-descriptions-item label="滞纳金"> {{lateFee}}</el-descriptions-item>
              <el-descriptions-item label="优惠金额">{{ discount }}</el-descriptions-item>
              <el-descriptions-item label="实际应收">{{receivable}}</el-descriptions-item>
              <el-descriptions-item label="可用预存款"> {{ preSaveMoney }} </el-descriptions-item>
              <el-descriptions-item label="预存款付款">{{ prePayMoney }}</el-descriptions-item>
              <el-descriptions-item label="找零结存">{{ changeMoney }}</el-descriptions-item>
              <el-descriptions-item label="找零金额">{{ changeMoney }}</el-descriptions-item>
            </el-descriptions>

            <div>
              <span>收款金额 </span>
              <el-input placeholder="请输入内容" v-model="input" style="width:120px" clearable>
              </el-input>
              <span style="margin-left: 20px">付款方式 </span>
              <el-select v-model="paymethod" style="width:140px" placeholder="请选择">
                <el-option v-for="(item, index) in paymethods" :key="index" :label="item.name" :value="item.code">
                </el-option>
              </el-select>
              <span> </span>
              <el-checkbox v-model="checked"> 预存款付款</el-checkbox>

              <el-checkbox v-model="checked1">找零结存</el-checkbox>
            </div>

          </div>

          <el-form-item style="margin-left: 300px">
            <el-button type="primary" @click="resetForms">取消</el-button>
            <el-button @click="submitForm">确定</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>

      <el-dialog title="历史记录" :visible.sync="visible11">
        <el-form :model="history" :rules="rules" ref="ruleForm" label-width="150px" class="demo-ruleForm">
          <div>
            <el-table :data="paymentPayLog" style="width: 100%">

              <el-table-column type="index" label="序号"></el-table-column>
              <el-table-column prop="feeItemName" label="打印" width="100%">
                <el-button type="text" @click="refund(scope.row)">打印</el-button>
              </el-table-column>
              <el-table-column prop="resourceName" label="编号" width="100%">
              </el-table-column>
              <el-table-column prop="name" label="收费项名" width="100%">
              </el-table-column>
              <el-table-column prop="payerName" label="客户姓名" width="100%">
              </el-table-column>
              <el-table-column prop="payTime" label="费用开始时间" width="120">
              </el-table-column>
              <el-table-column prop="creatorTime" label="费用结束时间" width="120">
              </el-table-column>
              <el-table-column prop="receivableMoney" label="金额" width="100%">
              </el-table-column>
            </el-table>
          </div>
          <el-form-item style="margin-left: 300px">
            <el-button type="primary" @click="visible11=false">取消</el-button>
            <el-button @click="visible11=false">确定</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>

    </div>

  </div>
</template>
<script>
export default {
  name: "controllerMoney",
  data() {
    return {
      checked: "true",
      checked1: "",
      paymethod: "",
      paymethods: [],
      input: "",
      id: "01-A-1-101",
      listId: [],
      dataResource: [],
      paymentContract: [],
      name: "",
      state: "对不对",
      state_end_time: "",
      building_square: "",
      use_square: "",
      user_trade: "",
      user_name: "",
      user_phone: "",
      begin_date: "",
      tableData3: [],
      tableD: [],

      Form: {
        resourceName: "",
        feeUser: "",
        feeItemName: "",
        paymethod: "",
        money: "",
        date1: "",
      },
      ruleForm4: {
        id: "",
        name: "",
        chargeitem: "",
        paymethod: "",
        money: "",
        date1: "",
      },
      ruleForm1: {
        uid: "",
        id: "",
        name: "",
        chargeitem: "",
        paymethod: "",
        money: "",
        date1: "",
        date2: "",
        backmethod: "",
        remark: "",
      },
      ruleForm2: {
        id: "",
        name: "",
        chargeitem: "",
        paymethod: "",
        money: "",
        date1: "",
      },
      ruleForm3: {
        id: "",
        name: "",
        paymethod: "",
        date1: "",
      },
      lateFee: "",
      discount: "",
      receivable: "",
      preSaveMoney: "",
      prePayMoney: "",
      changeMoney: "",

      chargeitem: "",

      activeName: "first",
      tableData: [],
      tableData1: [],
      tableData4: [],
      paymentPayLog: [],
      visible: false,
      visible1: false,
      ruleForm: [],
      table: [],
      configFeeItem: [],
      currentPage: 1,
      pageSize: 5,
      total: 0,
      currentPage1: 1,
      total1: 0,
      currentPage2: 1,
      total2: 0,
      currentPage4: 1,
      total4: 0,
      visible2: false,
      visible3: false,
      visible4: false,
      visible5: false,
      visible11: false,
      radio: "1",
      tableData2: [],
      history: "",
    };
  },
  methods: {
    // 获取分页信息

    handleSizeChange(pageSize) {
      this.depositList(this.currentPage, pageSize, "", "", "", "", "");
    },
    handleCurrentChange(pageNum) {
      this.depositList(pageNum, this.pageSize, "", "", "", "", "");
    },
    handleSizeChange4(pageSize) {
      this.paymentPreList(this.currentPage1, pageSize, "", "", "", "", "");
    },
    handleCurrentChange4(pageNum) {
      this.paymentPreList(pageNum, this.pageSize, "", "", "", "", "");
    },
    handleSizeChange2(pageSize) {
      this.paymentTempList(this.currentPage, pageSize, "", "", "", "", "");
    },
    handleCurrentChange2(pageNum) {
      this.paymentTempList(pageNum, this.pageSize, "", "", "", "", "");
    },
    add() {
      this.$http
        .post("http://localhost:8080/addPaymentDeposit", this.ruleForm)
        .then((response) => {
          this.visible5 = false;
          this.depositList();
        })
        .catch((error) => {
          console.log(error);
        });
    },
    submitForm3() {
      this.$http
        .post("http://localhost:8080/addPrePayment", this.ruleForm2)
        .then((response) => {
          this.visible3 = false;
          this.paymentTempList();
        })
        .catch((error) => {
          console.log(error);
        });
    },
    // 请求表格数据信息
    depositList(
      pageNum,
      pageSize,
      resourceName,
      feeUser,
      state,
      feeItemName,
      payType
    ) {
      this.$http
        .get("http://localhost:8080/depositList", {
          params: {
            pageNum: pageNum,
            pageSize: pageSize,
            resourceName: resourceName,
            feeUser: feeUser,
            state: state,
            feeItemName: feeItemName,
            payType: payType,
          },
        })
        .then((result) => {
          let $data = result.data; //表格数据
          this.tableData4 = $data.data.list; //当前页
          this.currentPage1 = $data.data.pageNum; //每页显示条数
          this.pageSize = $data.data.pageSize; //每页显示条数
          this.total1 = $data.data.total; //总条数
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },

    handleSelectionChange(val) {
      this.tableData1 = val;
      let money = 0;
      for (let i = 0; i < this.tableData1.length; i++) {
        money += parseFloat(this.tableData1[i].total);
      }
      this.receivable = money;
    },
    addForm() {
      this.$http
        .post("http://localhost:8080/addPaymentTemp", this.Form)
        .then((response) => {
          this.visible1 = false;
          this.selectPaymentTemp();
        })
        .catch((error) => {
          console.log(error);
        });
    },
    showplay() {
      this.visible = true;
    },

    showResourceName() {
      this.$http
        .get("http://localhost:8080/selectResourceName", {})
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.listId = datalist;
          this.showSelectMessage();
          this.PaymentContractMessage();
          this.configFeeItemName();
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    configFeeItemName() {
      this.$http
        .get("http://localhost:8080/configFeeItemName", {})
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.configFeeItem = datalist;
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    paymentPreList(
      pageNum,
      pageSize,
      resourceName,
      feeUser,
      type,
      feeItemName,
      payType
    ) {
      this.$http
        .get("http://localhost:8080/selectPaymentPreList", {
          params: {
            pageNum: pageNum,
            pageSize: pageSize,
            resourceName: resourceName,
            feeUser: feeUser,
            type: type,
            feeItemName: feeItemName,
            payType: payType,
          },
        })
        .then((result) => {
          let $data = result.data; //表格数据
          this.tableData3 = $data.data.list; //当前页
          this.currentPage4 = $data.data.pageNum; //每页显示条数
          this.pageSize = $data.data.pageSize; //每页显示条数
          this.total4 = $data.data.total; //总条数
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    submitForm1() {
      for (let i = 0; i < this.tableData2.length; i++) {
        const data = {
          resourceName: this.ruleForm1.id,
          payMethod: this.ruleForm1.paymethod,
          backTime: this.ruleForm1.date1,
          backmoney: this.tableData2[i].backmoney,
          ItemId: this.tableData2[i].feeItemId,
        };

        this.$http
          .post("http://localhost:8080/updatePrePaymentAccount", data)
          .then((response) => {
            this.visible1 = false;
          })
          .catch((error) => {
            console.log(error);
          });
      }
    },

    showSelectMessage() {
      this.$http
        .get("http://localhost:8080/centerMoney", {
          params: {
            resourceName: this.id,
          },
        })
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.dataResource = datalist;
          console.log(this.dataResource);
          this.name = this.dataResource[0].name;
          this.state = this.dataResource[0].state;
          this.state_end_time = this.dataResource[0].stateEndTime;
          this.building_square = this.dataResource[0].buildingSquare;
          this.use_square = this.dataResource[0].useSquare;
          this.Form.resourceName = this.dataResource[0].name;
          this.PaymentContractMessage();
          this.PaymentBillMessage();
          this.payment_method();
          this.selectPaymentTemp();
          this.PaymentPayLogMessage();
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    PaymentContractMessage() {
      this.$http
        .get("http://localhost:8080/selectPaymentContract", {
          params: {
            resourceName: this.id,
          },
        })
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.paymentContract = datalist;
          this.user_trade = this.paymentContract[0].userTrade;
          this.user_name = this.paymentContract[0].userName;
          this.user_phone = this.paymentContract[0].userPhone;
          this.begin_date = this.paymentContract[0].beginDate;

          this.Form.feeUser = this.paymentContract[0].userName;
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    PaymentBillMessage() {
      this.$http
        .get("http://localhost:8080/selectPaymentBill", {
          params: {
            resourceName: this.id,
          },
        })
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.tableData = datalist;
          this.lateFee = this.tableData[0].lateFee;
          this.discount = this.tableData[0].discount;
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    payment_method() {
      this.$http
        .get("http://localhost:8080/payment_method", {})
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.paymethods = datalist;
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    // 临时收费
    selectPaymentTemp() {
      this.$http
        .get("http://localhost:8080/selectPaymentTemp", {
          params: {
            resourceName: this.id,
          },
        })
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.table = datalist;
          this.ruleForm2.name = datalist[0].feeUser;
          this.ruleForm3.name = datalist[0].feeUser;
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    // / 请求表格数据信息
    selectPaymentPreAccount(id) {
      this.$http
        .get("http://localhost:8080/selectPayPreAccountMessage", {
          params: {
            resourceName: id,
          },
        })
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data.list;
          this.tableData2 = datalist;
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    handleInput(index, value) {
      // 获取当前行的账号金额
      let accountAmount = this.tableData2[index].amt;

      // 判断用户输入的退还金额是否小于等于账号金额
      if (value > accountAmount) {
        // 如果退还金额大于账号金额，则重置为账号金额
        this.tableData2[index].backmoney = accountAmount;
      }
    },
    // this.PaymentPayLogMessage() ;
    PaymentPayLogMessage() {
      this.$http
        .get("http://localhost:8080/selectPaymentPayLog", {
          params: {
            resourceName: this.id,
          },
        })
        .then((result) => {
          let $data = result.data;
          let datalist = $data.data;
          this.paymentPayLog = datalist;
          console.log(this.paymentPayLog);
          //  this.lateFeeMoney=this.paymentPayLog[0].lateFeeMoney
          //   this.discountMoney=this.paymentPayLog[0].discountMoney
          //   this.receivableMoney=this.paymentPayLog[0].receivableMoney
          //   this.preSaveMoney=this.paymentPayLog[0].preSaveMoney
          //   this.prePayMoney=this.paymentPayLog[0].prePayMoney
          //   this.changeMoney=this.paymentPayLog[0].changeMoney
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
  },
  mounted() {
    this.showResourceName();
    this.depositList(this.currentPage, this.pageSize, "", "", "", "", "");
    this.paymentTempList(pageNum, this.pageSize, "", "", "", "", "");
    this.paymentPreList(pageNum, this.pageSize, "", "", "", "", "");
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
.text {
  font-size: 14px;
}
.item {
  padding: 18px 0;
}
.box-card {
  width: 100%;
  margin-top: 0px;
}
</style>